const app = getApp()
Page({
  data: {
    spinShow: false,
    info: {},
    userName: null
  },

  onLoad: function (options) {
    let _this = this
    if (wx.getStorageSync('people') == 'student') {
      _this.setData({
        userName: '学生：' + app.globalData.student_info['name']
      })
    } else if (wx.getStorageSync('people') == 'teacher') {
      _this.setData({
        userName: '老师：' + app.globalData.teacher_info['name']
      })
    }
  },

  loadUserInfo() {
    let _this = this
    _this.setData({
      spinShow: true
    });
    app.formPost('/api/wx/student/user/current', null).then(res => {
      if (res.code == 1) {
        _this.setData({
          info: res.response
        });
      }
      _this.setData({
        spinShow: false
      });
    }).catch(e => {
      _this.setData({
        spinShow: false
      });
      app.message(e, 'error')
    })
  },

  logOut() {
    let _this = this
    wx.setStorageSync('myCode', null)
    wx.navigateTo({
      url: '/pages/user/bind/index',
    })
  },

  userknow: function () {
    wx.navigateTo({
      url: '../../user/userknow/userknow',
    })
  }
})